/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.edu.iuh.dhth7dlt.emailclient.ui;

import java.util.ArrayList;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import vn.edu.iuh.dhth7dlt.emailclient.utils.ConfigAccount;


/**
 *
 * @author Friendless
 */
public class AccountTreeModel implements TreeModel{   
   private  String []childs={"Họp Thư Đến","Thư Đã Gửi","Thùng Rác"};
   
    ArrayList<ConfigAccount> configAccounts;
    public AccountTreeModel( ArrayList<ConfigAccount> configAccounts)
    {
        this.configAccounts=configAccounts;
    }

    
    @Override
    public Object getRoot() {
       return "Locals";
    }

    @Override
    public Object getChild(Object parent, int index) {   
        if(!(parent instanceof ConfigAccount))
            return configAccounts.get(index);
       return childs[index]; 
        
                       
    }

    @Override
    public int getChildCount(Object parent){
           if(parent instanceof ConfigAccount)
               return childs.length;
           return configAccounts.size();
              
    }

    
    @Override
    public boolean isLeaf(Object node) {     
       if(node.equals(getRoot())|| (node instanceof ConfigAccount))
           return false;
       return true;
    }

    @Override
    public void valueForPathChanged(TreePath path, Object newValue) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public int getIndexOfChild(Object parent, Object child) {
        if(parent instanceof ConfigAccount)
        {
         ConfigAccount c =(ConfigAccount) child;
        }
      
        return 0;
    }

    @Override
    public void addTreeModelListener(TreeModelListener l) {
//        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void removeTreeModelListener(TreeModelListener l) {
      //  throw new UnsupportedOperationException("Not supported yet.");
    }
      
}
